var express = require('express');
var app = express();
//引入post请求需要的模块
var bodyParser = require('body-parser');
//接收post,指定为application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({extended:true}));

//引入控制器中的路由模块
var imgbox = require('./controller/imgbox');

var image = require('./controller/image');

//设置模板引擎
app.set('view engine','ejs');
//中间件
app.use(express.static('./static'));
//用get请求显示首页
app.get('/',imgbox.showImgbox);

//处理创建相册表单
app.post('/createBox',imgbox.addImgbox);

//照片页
app.get('/images/:id',image.showImages);

//找不到路由报404错误
app.use(function(req,res){
	res.end('404');
});


app.listen(3000);